﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using QiAdmin.Core;
using QiAdmin.Core.Attributes;
using QiAdmin.Core.Models;
using QiAdmin.Model.Dtos.Input;
using QiAdmin.Service.IService;
using QiAdmin.Service.Service;

namespace QiAdmin.WebApi.Controllers.System
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SysRoleController : ControllerBase
    {
        readonly ITSysRoleService _sysRoleService;
        public SysRoleController(ITSysRoleService sysRoleService, ITSysMenuService sysMenuService)
        {
            _sysRoleService = sysRoleService;
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult GetPageList(TSysRole_IN input)
        {
            var res = _sysRoleService.GetPageList(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Add)]
        [HttpPost]
        public ApiJsonResult Add(TSysRole_IN input)
        {
            var res = _sysRoleService.Add(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Edit)]
        [HttpPost]
        public ApiJsonResult Edit(TSysRole_IN input)
        {
            var res = _sysRoleService.Edit(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult Get(TSysRole_IN input)
        {
            var res = _sysRoleService.Get(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Delete)]
        [HttpPost]
        public ApiJsonResult RemoveRange(List<TSysRole_IN> input)
        {
            var res = _sysRoleService.RemoveRange(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult GetRoleTreeMenu(TSysRoleMenu_IN input)
        {
            var res = _sysRoleService.GetRoleTreeMenu(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.System)]
        [HttpPost]
        public ApiJsonResult SetRoleMenu(List<TSysRoleMenu_IN> input)
        {
            var res = _sysRoleService.SetRoleMenu(input);
            return ApiJsonResult.Convert(res);
        }

        [Permission(PermissionType.Query)]
        [HttpPost]
        public ApiJsonResult GetRoleTreeDept(TSysRole_IN input)
        {
            var res = _sysRoleService.GetRoleTreeDept(input);
            return ApiJsonResult.Convert(res);
        }
    }
}
